package com.cg.cgms.service.impl;

import com.cg.cgms.mapper.ShopMapper;
import com.cg.cgms.utils.WeChatUtil;
import com.cg.cgms.pojo.Shop;
import com.cg.cgms.pojo.UserLove;
import com.cg.cgms.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class ShopServiceImpl implements ShopService {

    @Autowired
    private ShopMapper shopMapper;
    @Override
    public Shop findBySsid(Integer ssid) {
        Shop shop=shopMapper.findBYSsid(ssid);
        return shop;
    }

    @Override
    public ArrayList<Shop> findByName(String name) {
        ArrayList<Shop> shops=shopMapper.findByName(name);
        return shops;
    }
    //搜索功能，根据店铺种类查询店铺
    @Override
    public ArrayList<Shop> findByType(String type) {
        ArrayList<Shop> shops=shopMapper.findByType(type);
        return shops;
    }

    @Override
    public String findcode(String code) {
        WeChatUtil.getOpenId(code);
        return WeChatUtil.getOpenId(code);
    }

    @Override
    public ArrayList<UserLove> userLove(String openid) {
        ArrayList<UserLove> userLoves =shopMapper.userLvoe(openid);
        System.out.println(userLoves);
        return userLoves;
    }

    @Override
    public ArrayList<Shop> findByTA(String address, String type) {
        ArrayList<Shop> shops=shopMapper.findByTA(address,type);
        return shops;
    }
}
